//
//  SearchController.m
//  谈诗说词
//
//  Created by dllo on 15/6/13.
//  Copyright (c) 2015年 lanou3g.com蓝鸥科技. All rights reserved.
//

#import "SearchController.h"
#import "SearchListController.h"
#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height
@interface SearchController ()

@end

@implementation SearchController
- (void)dealloc
{
    
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 0.32 * WIDTH, 0.08 * WIDTH)];
    title.text = @"搜索";
    title.font = [UIFont fontWithName:@"-" size:28];
    title.textAlignment = 1;
    self.navigationItem.titleView = title;
    
    UIImageView *background = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 64)];
    [background setImage:[UIImage imageNamed:@"搜索背景.png"]];
    [self.view  addSubview:background];
    [self createView];
}


- (void)createView
{
    self.searchField = [[UITextField alloc]initWithFrame:CGRectMake(0.04 * WIDTH, 0.04 * WIDTH, WIDTH - 0.17 * WIDTH, 0.13 * WIDTH)];
    
    self.searchField.borderStyle = UITextBorderStyleRoundedRect;
    self.searchField.placeholder = @"诗名/作者";
    [self.view addSubview:self.searchField];
    
    UILabel *tips = [[UILabel alloc]initWithFrame:CGRectMake(0.04 * WIDTH, 0.22 *WIDTH, 0.21 * WIDTH, 0.1 * WIDTH)];
    tips.text = @"热门搜索";
    tips.font = [UIFont systemFontOfSize:15];
    tips.textColor = [UIColor grayColor];
    [self.view addSubview:tips];
    
    UIButton *libai = [[UIButton alloc]initWithFrame:CGRectMake(0.04 * WIDTH, 0.35 * WIDTH, 0.21 * WIDTH, 0.1 * WIDTH)];
    [libai setTitle:@"李白" forState:UIControlStateNormal];
    [libai setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [libai addTarget:self action:@selector(libaiAction) forControlEvents:UIControlEventTouchUpInside];
    libai.titleLabel.font = [UIFont fontWithName:@"-" size:25];
    [self.view addSubview:libai];
    
    UIButton *dufu = [[UIButton alloc]initWithFrame:CGRectMake(0.34 * WIDTH, 0.35 * WIDTH, 0.21 * WIDTH, 0.1 * WIDTH)];
    [dufu setTitle:@"杜甫" forState:UIControlStateNormal];
    [dufu setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [dufu addTarget:self action:@selector(dufuAction) forControlEvents:UIControlEventTouchUpInside];
    dufu.titleLabel.font = [UIFont fontWithName:@"-" size:25];
    [self.view addSubview:dufu];
    
    
    UIButton *mhr = [[UIButton alloc]initWithFrame:CGRectMake(0.7 * WIDTH, 0.35 * WIDTH, 0.21 * WIDTH, 0.1 * WIDTH)];
    [mhr setTitle:@"孟浩然" forState:UIControlStateNormal];
    [mhr setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [mhr addTarget:self action:@selector(mhrAction) forControlEvents:UIControlEventTouchUpInside];
    mhr.titleLabel.font = [UIFont fontWithName:@"-" size:25];
    [self.view addSubview:mhr];
    
    UIButton *wangwei = [[UIButton alloc]initWithFrame:CGRectMake(0.04 * WIDTH, 0.5 * WIDTH, 0.21 * WIDTH, 0.1 * WIDTH)];
    [wangwei  setTitle:@"王维" forState:UIControlStateNormal];
    [wangwei  setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [wangwei addTarget:self action:@selector(wangweiAction) forControlEvents:UIControlEventTouchUpInside];
    wangwei .titleLabel.font = [UIFont fontWithName:@"-" size:25];
    [self.view addSubview:wangwei];
    
    
    UIButton *lqz = [[UIButton alloc]initWithFrame:CGRectMake(0.34 * WIDTH, 0.5 * WIDTH, 0.21 * WIDTH, 0.1 * WIDTH)];
    [lqz  setTitle:@"李清照" forState:UIControlStateNormal];
    [lqz  setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [lqz addTarget:self action:@selector(lqzAction) forControlEvents:UIControlEventTouchUpInside];
    lqz.titleLabel.font = [UIFont fontWithName:@"-" size:25];
    [self.view addSubview:lqz];
    
    
    UIButton *dumu = [[UIButton alloc]initWithFrame:CGRectMake(0.7 * WIDTH, 0.5 * WIDTH, 0.21 * WIDTH, 0.1 * WIDTH)];
    [dumu  setTitle:@"杜牧" forState:UIControlStateNormal];
    [dumu setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [dumu addTarget:self action:@selector(dumuAction) forControlEvents:UIControlEventTouchUpInside];
    dumu.titleLabel.font = [UIFont fontWithName:@"-" size:25];
    [self.view addSubview:dumu];
    
    
    UIButton *lsy = [[UIButton alloc]initWithFrame:CGRectMake(0.07 * WIDTH, 0.65* WIDTH, 0.21 * WIDTH, 0.1 * WIDTH)];
    [lsy  setTitle:@"李商隐" forState:UIControlStateNormal];
    [lsy  setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [lsy addTarget:self action:@selector(lsyAction) forControlEvents:UIControlEventTouchUpInside];
    lsy.titleLabel.font = [UIFont fontWithName:@"-" size:25];
    [self.view addSubview:lsy];
    
    
    
    
    
    UIButton *searchButton = [[UIButton alloc]initWithFrame:CGRectMake(0.04*WIDTH + self.searchField.frame.size.width, 0.05 * WIDTH, 0.133 *WIDTH, 0.1093 * WIDTH)];
    [searchButton setImage:[UIImage imageNamed:@"搜索按钮.png"] forState:UIControlStateNormal];
    [searchButton addTarget:self action:@selector(searchAction:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:searchButton];
    
}

- (void)searchAction:(id)sender
{
    SearchListController *list = [[SearchListController alloc]init];
    list.key = self.searchField.text;
    [self.navigationController pushViewController:list animated:YES];
    
}

- (void)libaiAction
{
    SearchListController *list = [[SearchListController alloc]init];
    list.key = @"李白";
    [self.navigationController pushViewController:list animated:YES];

}

- (void)dufuAction
{
    SearchListController *list = [[SearchListController alloc]init];
    list.key = @"杜甫";
    [self.navigationController pushViewController:list animated:YES];

}

- (void)mhrAction
{
    SearchListController *list = [[SearchListController alloc]init];
    list.key = @"孟浩然";
    [self.navigationController pushViewController:list animated:YES];

}

- (void)wangweiAction
{
    SearchListController *list = [[SearchListController alloc]init];
    list.key = @"王维";
    [self.navigationController pushViewController:list animated:YES];

}

- (void)lqzAction
{
    SearchListController *list = [[SearchListController alloc]init];
    list.key = @"李清照";
    [self.navigationController pushViewController:list animated:YES];
 
}

- (void)dumuAction
{
    SearchListController *list = [[SearchListController alloc]init];
    list.key = @"杜牧";
    [self.navigationController pushViewController:list animated:YES];

}

- (void)lsyAction
{
    SearchListController *list = [[SearchListController alloc]init];
    list.key = @"李商隐";
    [self.navigationController pushViewController:list animated:YES];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
}



@end
